package cn.sciento.iam.domain.entity;


import cn.sciento.starter.keyencrypt.core.Encrypt;
import io.choerodon.mybatis.annotation.ColumnType;
import io.choerodon.mybatis.annotation.ModifyAudit;
import io.choerodon.mybatis.annotation.VersionAudit;
import io.choerodon.mybatis.domain.AuditDomain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;


@ApiModel(value = "子模块管理")
@VersionAudit
@ModifyAudit
@Table(name = "iam_sub_module")
public class SubModule extends AuditDomain {

    public static final String FIELD_ID = "id";
    public static final String FIELD_CODE = "code";
    public static final String FIELD_NAME = "name";
    public static final String FIELD_SORT = "sort";
    public static final String FIELD_ICON = "icon";
    public static final String FIELD_ROUTE = "route";
    public static final String FIELD_ENABLED_FLAG = "enabledFlag";
    public static final String FIELD_DESCRIPTION = "description";

    @Id
    @GeneratedValue
    @Encrypt
    private Long id;

    @ApiModelProperty("编号")
    @NotBlank
    private String code;

    @ApiModelProperty("名称")
    @NotBlank
    private String name;

    @ApiModelProperty("排序")
    private Integer sort;

    @ApiModelProperty("图标")
    private String icon;

    @ApiModelProperty("路由地址")
    private String route;

    @ApiModelProperty("可用标志")
    private Boolean enabledFlag;

    @ApiModelProperty("描述")
    private String description;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getRoute() {
        return route;
    }

    public void setRoute(String route) {
        this.route = route;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getEnabledFlag() {
        return enabledFlag;
    }

    public void setEnabledFlag(Boolean enabledFlag) {
        this.enabledFlag = enabledFlag;
    }

    public void disable(){
        this.enabledFlag = false;
    }

    public void enable(){
        this.enabledFlag = true;
    }

    @Override
    public String toString() {
        return "SubModule{" +
                "id=" + id +
                ", code='" + code + '\'' +
                ", name='" + name + '\'' +
                ", sort=" + sort +
                ", icon='" + icon + '\'' +
                ", route='" + route + '\'' +
                ", enabledFlag=" + enabledFlag +
                ", description='" + description + '\'' +
                '}';
    }
}
